#include "MockDB.h"
#include "MockTables.h"
#include "memdb/error/MemdbError.h"

namespace memdb {
namespace impl {
namespace mock {

MockDB::MockDB()
  : _tables(new MockTables())
{
}

MockDB::~MockDB(){
  delete _tables;
}

std::error_code MockDB::open() {
  _opened = true;
  return memdb::error::ok;
}
std::error_code MockDB::close() {
  _opened = false;
  return memdb::error::ok;
}

bool MockDB::exists() const {
  return true;
}

std::error_code MockDB::destroy() {
  delete _tables;
  _tables = new MockTables();  
  return memdb::error::ok;
}

ITables & MockDB::tables() const {
  return *_tables;
}

}//namespace mock
}//namespace impl
}//namespace memdb
